package com.gitee.swsk33.gatewaydemo.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

@Configuration
public class MyKeyResolver {

	@Bean
	public KeyResolver ipKeyResolver() {
		// 根据ip限流
		return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
	}

}